package study.corejava.extend;


class Manager extends Employee {
	
	//子类新的属性
	private double bonus;
	
	public Manager(String n, double s, int year, int month, int day) {
		
		//当没有指定调用的父类构造器时，会默认调用父类无参数的构造器，若父类没有定义无参数的构造器，则不能通过编译
		super(n, s, year, month, day); 
		//super();
		bonus = 0;
	}

	public double getSalary() {
		double baseSalary = super.getSalary();
		return baseSalary + bonus;
	}

	public void setBonus(double b) {
		bonus = b;
	}
	
	public double getBonus() {
		return bonus;
	}
	
	//重写父类Employee的equals方法
	public boolean equals(Object otherObject) {
		if (!super.equals(otherObject))
			return false;
		Manager other = (Manager) otherObject;
		// super.equals checked that this and other belong to the same class
		return bonus == other.bonus;
		
	}
	
	//重写父类飞hashCode方法
	public int hashCode() {
		return super.hashCode() + 17 * new Double(bonus).hashCode();
	}
	
	//重写父类的toString方法
	public String toString() {
		return super.toString() + "[bonus=" + bonus + "]";
	}

}
